//
//  RTJReimbursementView.m
//  RuiTaiJinProject
//
//  Created by jayson on 2019/4/2.
//  Copyright © 2019年 leewei. All rights reserved.
//

#import "RTJReimbursementView.h"
#import "LewPopupViewController.h"
#import "RTJForgetPassWordController.h"

@interface RTJReimbursementView ()<UITextFieldDelegate,ZXRegTextFieldDelegate>


@end

@implementation RTJReimbursementView

+ (instancetype)defaultViewWithFrame:(CGRect)rect data:(NSDictionary *)data{
    
    return [[RTJReimbursementView alloc]initWithFrame:rect data:data];
    
}

- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)data
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [[NSBundle mainBundle] loadNibNamed:[[self class] description] owner:self options:nil];
        
        _bg_view.frame = frame;
        [self addSubview:_bg_view];
        
        _bg_view.layer.masksToBounds = YES;
        _bg_view.layer.cornerRadius = 9;
        
        _pswFld.layer.cornerRadius = _pswFld.height/2;
        _pswFld.layer.masksToBounds = YES;
        _pswFld.layer.borderColor = [UIColor colorForHex:@"#E6E6E6"].CGColor;
        _pswFld.layer.borderWidth = 1;
        
        _pswFld.delegate = self;
        _pswFld.zxdelegate = self;
        _pswFld.zxType = ZXRegTextFieldTypeChars;
        _pswFld.secureTextEntry = YES;
        
        _lab1.text = [NSString stringWithFormat:@"%@元",data[@"true_total_repay_money"]];
        _lab2.text = [NSString stringWithFormat:@"%@元",data[@"total_repay_money"]];

        
    }
    return self;
}

- (IBAction)forgetPsw:(id)sender {
    
    [_parentVC lew_dismissPopupView];

    RTJForgetPassWordController *vc = [[RTJForgetPassWordController alloc]init];
    vc.isPayPassWord = YES;
    vc.title = @"找回支付密码";
    [_parentVC.navigationController pushViewController:vc animated:YES];
}

- (IBAction)cancel:(id)sender {
    
    [_parentVC lew_dismissPopupView];

}

- (IBAction)sure:(id)sender {
    
    if (self.sureClick) {
        
        self.sureClick(_pswFld.text);
    }
    
    [_parentVC lew_dismissPopupView];
}

-(void)withSureClick:(ReimbursementBlock)block{
    
    _sureClick = block;
}
@end
